﻿

@{
    Layout = "";
}
<style>
    .ngdialog.ngdialog-theme-plain .ngdialog-content {
        width: 25% !important;
    }
</style>
<div ng-controller="MemberListController">
    <h3>会员管理</h3>

    <div class="panel panel-default" ng-class="{ 'whirl standard': isLoading}">
        <div class="panel-heading">
            <div class="form-inline ng-pristine ng-valid">
                <div class="form-group">
                    <input id="input-email" placeholder="会员昵称" class="form-control" type="text" ng-model="Keywords">
                    <select ng-model="MemberLevel" class="form-control">
                        <option value="0">会员等级</option>
                        <option value="1">普通会员</option>
                        <option value="2">白银会员</option>
                        <option value="3">黄金会员</option>
                        <option value="4">钻石会员</option>
                        <option value="5">至尊会员</option>
                    </select>
                    <button type="submit" class="btn btn-labeled btn-primary" ng-click="tableParams.$params.page = 1;tableParams.reload()">
                        <span class="btn-label">
                            <em class="fa fa-search"></em>
                        </span>搜索
                    </button>
                </div>
                @*<div class="form-group">
                    <button type="submit" class="btn btn-labeled btn-success" ng-click="positionManagementUpdataView(0)">
                        <span class="btn-label">
                            <em class="fa fa-plus"></em>
                        </span>新增
                    </button>
                </div>*@
                <div class="form-group">
                    <button type="button" class="btn btn-labeled btn-success" ng-click="godt()">
                        <span class="btn-label">
                            <em class="fa fa-plus"></em>
                        </span>导出报表
                    </button>
                </div>
            </div>
        </div>
        <div class="panel-body">
            <div class="table-responsive">
                <table ng-table="tableParams" class="table table-striped table-bproducted table-hover">
                    <tbody>
                        <tr ng-repeat="item in $data">
                            <td data-title="'会员Id'" class="text-center">{{item.Id}}</td>
                            <td data-title="'会员昵称'" class="text-center">{{item.NickName}}</td>
                            <td data-title="'会员等级'" class="text-center">{{item.LevelDes}}</td>
                            <td data-title="'余额'" class="text-center">{{item.Balance}}</td>
                            <td data-title="'积分'" class="text-center">{{item.Points}}</td>
                            <td data-title="'关注时间'" class="text-center">{{item.AddTime}}</td>
                            <td data-title="'操作'" nowrap="nowrap" class="text-center">
                                <button type="button" ng-click="memberAddress(item.Id)" class="btn btn-sm btn-primary" title="地址">
                                    <em class="fa fa-home"></em>
                                </button>
                                <button type="button" ng-click="memberRecharge(item.Id)" class="btn btn-sm btn-primary" title="资金">
                                    <em class="glyphicon glyphicon-yen"></em>
                                </button>

                                <button type="button" ng-click="memberDetail(item.Id)" class="btn btn-sm btn-edit" title="编辑">
                                    <em class="fa fa-edit"></em>
                                </button>
                               
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
<script>
    App.controller('MemberListController', [
    '$scope', '$resource', '$state', '$route', '$http', 'ngTableParams', 'ngTableDataService', 'Notify', '$filter', 'ngDialog', "$stateParams", "$timeout", "toaster",
        function ($scope, $resource, $state, $route, $http, ngTableParams, ngTableDataService, Notify, $filter, ngDialog, $stateParams, $timeout, toaster) {
            'use strict';
            $scope.MemberLevel = 0;

            $scope.isLoading = true;
            //数据查询
            $scope.tableParams = new ngTableParams({
                page: 1,
                count: 10,
                sorting: {
                    Id: 'desc'     // 初始化排序
                }
            }, {
                getData: function ($defer, params) {
                    $scope.isLoading = true;
                    var requestParams = {
                        Skip: (params.page() - 1) * params.count(),
                        Take: params.count(),
                        Keywords: $scope.Keywords,
                        MemberLevel: $scope.MemberLevel
                    };
                    $http.post('/Member/GetMemberList', ngTableDataService.getServerSideParams(params.orderBy().toString(), params, requestParams))
                        .success(function (data, status) {
                            params.total(data.Total);
                            $defer.resolve(data.Results);
                            $scope.isLoading = false;
                        });
                }
            });

            $scope.godt = function () {
               
                var keyword = "";
                if ($scope.Keywords != undefined)
                {
                    keyword = $scope.Keywords;
                }

                location.href = "/Report/GetMemberList?Keywords=" + keyword + "&MemberLevel=" + $scope.MemberLevel;
            }

            //跳转更新新增页面
            $scope.positionManagementUpdataView = function (positionCenter) {
                if (positionCenter == 0) {
                    $scope.Position = {};
                } else {
                    $scope.Position = angular.copy(positionCenter);
                }
                ngDialog.openConfirm({
                    template: 'setUpTempDialogId',
                    className: 'ngdialog-theme-plain',
                    scope: $scope
                }).then(function (value) {
                }, function (reason) {
                }
                );
            }

            //跳转更新页面
            $scope.memberDetail = function (id) {
                $state.go('app.memberdetail', { "id": id });
            }

            //跳转地址页面
            $scope.memberAddress = function (id) {
                $state.go('app.address', { "id": id });
            }
            //跳转资金页面
            $scope.memberRecharge = function (id) {
                $state.go('app.recharge', { "id": id });
            }
          
        }
    ]);
</script>
